﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using blackhouse.WebNemo.Business.Groups;
using blackhouse.WebNemo.Data.Cache;

namespace blackhouse.WebNemo.Business {
    public class CacheGroupIdsProvider : IGroupIdsProvider {

        #region Fields

        private readonly int[] groupIds;

        #endregion

        #region Constructors

        public CacheGroupIdsProvider(params string[] groupNames) {
            var factory = Factory.Instance();
            this.groupIds =
                (from t in groupNames
                 select factory.GetGroup(t)
                     into @group
                     where @group != null && @group.Exists
                     select @group.Id).ToArray();
        }

        #endregion

        #region Methods

        public int[] GetIds() {
            return this.groupIds;
        }

        #endregion

    }
}
